package com.cdream.basic.algorithm.leetcode.array;

import java.util.Arrays;

/**
 * @author cdream
 * @date 2021/12/27
 */
public class Question825 {
    public int numFriendRequests(int[] ages) {
        Arrays.sort(ages);
        int sum = 0;
        for(int i = ages.length-1; i>0; i--){
            for(int j = i-1; j>=0;j--){
                if(ages[i]==ages[j]){
                    sum+=2;
                } else if(isSuitable(ages[j],ages[i])){
                    sum++;
                }
            }
        }
        return sum;
    }
    boolean isSuitable(int y,int x){
        if(x > 100 && y < 100){
            return false;
        }
        if (y * 0.5 +7 >= x){
            return false;
        }
        return true;
    }

    public static void main(String[] args) {
        new Question825().numFriendRequests(new int[]{16,17,18});
    }
}
